/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package xml.valueobject2;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import xml.utils.DBUtils;

/**
 *
 * @author CHIP
 */
public class NewsJAXPProcessor {
NewsList newslist = new NewsList();
public NewsJAXPProcessor(){
    Connection con = null;
    CallableStatement call = null;
    ResultSet rs = null;   

        try {
            con = DBUtils.makeConnection();
            call = con.prepareCall("{call getListNews()}");
            rs = call.executeQuery();

            int id = 0;
            String title = "";
            String date = "";
            String description = "";
            String imageUrl = "";
            String email = "";

            while (rs.next()){
                id = rs.getInt("id");
                title = rs.getString("title");
                date = rs.getString("date");
                description = rs.getString("description");
                imageUrl = rs.getString("imageUrl");
                email = rs.getString("email");

                News news = new News(id, title, date, description, imageUrl, email);
                newslist.getListInfo().add(news);
            }

        } catch (SQLException ex) {
            Logger.getLogger(NewsJAXPProcessor.class.getName()).log(Level.SEVERE, null, ex);
        }

}
}
